package com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.supplier;

import com.iwhalecloud.bss.kite.cucc.service.custview.userinfo.UserAttrSupplier;
import com.iwhalecloud.bss.kite.dataservice.cache.AttrValueCache;
import com.iwhalecloud.bss.kite.dataservice.entity.AttrValue;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * 14 计费周期 ORD10235
 */
@Service
@UserAttrSupplier(attrField = "ORD10235")
public class ChargeCycleSupplier extends AbstractUserAttrSupplier {

    @Override
    public String getValue() {
        return Optional.ofNullable(String.valueOf(userInfoContext.getUserInfo().get("CHARGE_CYCLE"))).orElse("");
    }

    @Override
    public String getValueDesc() {
        String chargeCycleValue = getValue();
        return Optional.ofNullable(AttrValueCache.getAttrValue("2020111104", chargeCycleValue))
            .map(AttrValue::getAttrValueName).orElse(chargeCycleValue);
    }
}
